<template>
  <el-form :inline="true">
    <el-form-item label="关键字">
      <el-input v-model="searchParams.keyWords" placeholder="输入关键字" />
    </el-form-item>
    <el-form-item label="创建时间">
      <el-date-picker
        v-model="searchParams.time"
        type="daterange"
        range-separator="至"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        format="YYYY/MM/DD"
        value-format="YYYY-MM-DD"
      />
    </el-form-item>
    <el-form-item>
      <el-button :icon="Search" @click="onSearch" />
    </el-form-item>
  </el-form>
</template>

<script>
import { Search } from "@element-plus/icons-vue";
export default {
  data() {
    return {
      Search,
      searchParams: {
        keyWords: "",
        time: [],
      },
    };
  },
  methods: {
    onSearch() {
      // 点击搜索
      this.$emit("onSearch", {
        keyWords: this.searchParams.keyWords,
        start: this.searchParams.time[0],
        end: this.searchParams.time[1],
      });
      this.searchParams = {
        keyWords: "",
        time: [],
      };
    },
  },
};
</script>

<style lang="scss" scoped></style>
